﻿using Super.Collection.Visual.Workers;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Super.Collection.Visual
{
	public partial class MainForm : Form
	{
		public MainForm()
		{
			InitializeComponent();
		}

		private void MainForm_Load(object sender, EventArgs e)
		{

		}

		/// <summary>
		/// 采集工作者
		/// </summary>
		private void RunWorker()
		{
			List<IWorker> workers = new List<IWorker>();
			workers.Add(new ShuangSeQiuWorker());

			while (true)
			{
				foreach (var worker in workers)
				{
					worker.Run();
				}

				Thread.Sleep(60000);
			}
		}

		private void btnOK_Click(object sender, EventArgs e)
		{
			ShuangSeQiuWorker worker = new ShuangSeQiuWorker();

			worker.Run();
		}

		private void btnStart_Click(object sender, EventArgs e)
		{
			this.btnStart.Enabled = false;

			Thread thread = new Thread(RunWorker);
			thread.Start();

			this.btnStop.Enabled = true;
		}

		private void btnStop_Click(object sender, EventArgs e)
		{
			this.btnStop.Enabled = false;

			this.btnStart.Enabled = true;
		}
	}
}
